AEAD architecture: FAuthObj + multi-call GCM (from PR #90 concern A)#102
Open
omonien wants to merge 1 commit into
Open
AEAD architecture: FAuthObj + multi-call GCM (from PR #90 concern A)#102omonien wants to merge 1 commit into
omonien wants to merge 1 commit into
Conversation
…m#99) Extract Concern A from the ChaCha PR MHumm#90 donor without ChaCha/Poly1305. - Polymorphic FAuthObj replaces dual FGCM/FCCM fields; public IDECAuthenticatedCipher unchanged - Keep EncodeGCM/DecodeGCM/EncodeCCM/DecodeCCM as protected wrappers (no rename break) - GCM multi-call: absorb PR MHumm#99 streaming (GHASH partial + CTR keystream remainder + Done/FFinalized) - Reject PR MHumm#90 fIsLastBlock CTR model (incorrect for unaligned multi-chunk) - Base Done virtual (no-op for CCM one-shot); TDECCipherModes.Done finalizes then verifies ExpectedTag - InitMode always FreeAndNil(FAuthObj) before recreate (leak fix) - Multi-chunk and Done-lifecycle unit tests; corrected large GCM rsp tag See Docs/plans/2026-07-25-aead-architecture.md.
omonien
force-pushed
the
package/aead-architecture
branch
from
July 27, 2026 09:17
47c7463 to
58b54d1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For Markus — AEAD architecture (no ChaCha)
This is package A only: a careful architecture / GCM fix extracted from donor PR #90.
ChaCha / XChaCha / Poly1305 / AES-NI are not in this PR. Those stay separate packages on the fork for later.
Why bother (simple words)
Today, authenticated modes (especially GCM) are a bit of a special case:
This PR does three practical things:
FAuthObjinstead of dualFGCM/FCCMwiring.Encode/Decodecalls; the tag is finalized inDone.Init → (AAD / tag length) → Encode/Decode* → Done → read / check tag.Benefits for existing code (already, without ChaCha)
You get value even if we never merge ChaCha:
Initcase FMode ofduplication for auth properties / DoneFAuthObjimplementation without rewriting GCM againIDECAuthenticatedCiphernames stay; protectedEncodeGCM/DecodeGCMkept as wrappersCall site note: for multi-call GCM, call
Donebefore readingCalculatedAuthenticationResult. Paths that already callDone(most of the suite / normal demo style) keep working. Single-shot “encode then Done then tag” remains the normal pattern.CCM stays one-shot as before (no fake multi-chunk for CCM).
Relation to the donor PR (#90)
PR #90 mixed architecture, GCM rewrite, ChaCha, Poly1305, SIMD, AES-NI, … in one large change.
For this package we:
So: donor as inspiration and reference, not a bulk merge.
What changed (files)
Source/DECAuthenticatedCipherModesBase.pasDoneSource/DECCipherModes.pasFAuthObjwiring, leak-safeInitMode, unified finalize + ExpectedTag checkSource/DECCipherModesGCM.pasFFinalized)Unit Tests/Tests/TestDECCipherModesGCM.pasUnit Tests/Data/gcmEncryptExtIV256_large.rspDocs/plans/2026-07-25-aead-architecture.mdTests (emphasis)
Thorough coverage was a hard requirement for this package — architecture without a green GCM/CCM signal is not mergeable.
Verified locally (Delphi 13, Win32 Console DUnit):
InitRisk
Medium — touches core GCM authentication. Mitigations: multi-chunk NIST-style vectors, Done lifecycle tests, CCM full regression, no public interface rename.
Out of scope (intentionally)
cmPoly1305Suggested review order
Init→ multiEncode/Decode→Done→ tagFFinalizedFAuthObj+ property / Done wiring inDECCipherModes.pasTest plan
Happy to adjust wording or split further if anything feels too large.